package com.wgke.bluetooth.utils;

import static android.os.Build.VERSION_CODES.R;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import androidx.annotation.NonNull;

import java.util.HashMap;
import java.util.Map;

/**
 * toast 管理
 */
public class ToastUtil {

    private static Map<String, Long> map = new HashMap<>();

    private ToastUtil() {
        throw new IllegalStateException("Utility class");
    }

    /**
     * 简单toast
     */
    public static Toast showMsg(String msg) {
        if (TextUtils.isEmpty(msg)) return null;
        if (Looper.getMainLooper() == Looper.myLooper()) {
            Toast toast = Toast.makeText(CommonUtil.getContext(), "" + msg, Toast.LENGTH_SHORT);
            toast.show();
            return toast;
        }
        return null;
    }

    public static Toast showLongMsg(String msg) {
        if (TextUtils.isEmpty(msg)) return null;
        if (Looper.getMainLooper() == Looper.myLooper()) {
            Toast toast = Toast.makeText(CommonUtil.getContext(), msg, Toast.LENGTH_LONG);
            toast.show();
            return toast;
        }
        return null;
    }

}
